//
//  ShowViewController.m
//  News
//
//  Created by xalo on 16/3/10.
//  Copyright © 2016年 News. All rights reserved.
//

#import "ShowViewController.h"
#import "UMSocial.h"
#import "VideoModel.h"



@interface ShowViewController ()


@property (strong, nonatomic) IBOutlet UIView *CancelButton;

@property (strong, nonatomic) IBOutlet UIView *shareView;


@property (strong, nonatomic) IBOutlet UIView *clearView;
@property (nonatomic,strong) UIVisualEffectView *effectView;


@property (strong, nonatomic) IBOutlet UIButton *qqZone;

@property (strong, nonatomic) IBOutlet UIButton *qqWeibo;


@property (strong, nonatomic) IBOutlet UIButton *renren;


@property (strong, nonatomic) IBOutlet UIButton *faceBook;

@property (strong, nonatomic) IBOutlet UIButton *sina;


@property (strong, nonatomic) IBOutlet UIButton *friendster;


@property (strong, nonatomic) IBOutlet UIButton *QQ;


@property (strong, nonatomic) IBOutlet UIButton *weixin;






@end

@implementation ShowViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    
    
    self.CancelButton.layer.cornerRadius = 10;
    self.CancelButton.layer.masksToBounds = YES;
    self.shareView.layer.cornerRadius = 10;
    self.shareView.layer.masksToBounds = YES;
    
    [self showVisualView];
    
    [self.clearView addSubview:self.pictureView];
    
    
//    [self setButtonBorder];
    
    // Do any additional setup after loading the view.
}





//设置毛玻璃效果
-(void)showVisualView
{
    
    self.effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:(UIBlurEffectStyleDark)]];
    
    self.effectView.frame = [UIScreen mainScreen].bounds;
    self.effectView.alpha = 1;
    
    [self.pictureView addSubview:self.effectView];
    
}


//设置按钮边框
-(void)setButtonBorder {

    
    [self.qqZone.layer setBorderWidth:0.5];
    [self.qqZone.layer setBorderColor:(CGColorRef)[UIColor lightGrayColor].CGColor];
    [self.qqWeibo.layer setBorderWidth:0.5];
    [self.qqWeibo.layer setBorderColor:(CGColorRef)[UIColor lightGrayColor].CGColor];
    [self.renren.layer setBorderWidth:0.5];
    [self.renren.layer setBorderColor:(CGColorRef)[UIColor lightGrayColor].CGColor];
    [self.faceBook.layer setBorderWidth:0.5];
    [self.faceBook.layer setBorderColor:(CGColorRef)[UIColor lightGrayColor].CGColor];
    [self.sina.layer setBorderWidth:0.5];
    [self.sina.layer setBorderColor:(CGColorRef)[UIColor lightGrayColor].CGColor];
    [self.weixin.layer setBorderWidth:0.5];
    [self.weixin.layer setBorderColor:(CGColorRef)[UIColor lightGrayColor].CGColor];
    [self.friendster.layer setBorderWidth:0.5];
    [self.friendster.layer setBorderColor:(CGColorRef)[UIColor lightGrayColor].CGColor];
    [self.QQ.layer setBorderWidth:0.5];
    [self.QQ.layer setBorderColor:(CGColorRef)[UIColor lightGrayColor].CGColor];


}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/



- (IBAction)cancelButtonAction:(UIButton *)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}



- (IBAction)shareAction:(UIButton *)sender {
    
    NSInteger tag = sender.tag;

    
    
    
    
    
    
    
    
    if (tag == 101) {
        
      
       UMSocialUrlResource *url = [[UMSocialUrlResource alloc]initWithSnsResourceType:(UMSocialUrlResourceTypeVideo) url:self.link];
        
        [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToDouban] content:[NSString stringWithFormat:@"%@",self.tit] image:nil location:nil urlResource:url presentedController:self completion:^(UMSocialResponseEntity *response){

            
            if (response.responseCode == UMSResponseCodeSuccess) {
                NSLog(@"分享成功！");
            }
        }];


        NSLog(@"新浪东风乡");
        

 
  
        
    }else if (tag == 102){
    
       UMSocialUrlResource *url = [[UMSocialUrlResource alloc]initWithSnsResourceType:(UMSocialUrlResourceTypeVideo) url:self.link];
        
    [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatSession] content:[NSString stringWithFormat:@"%@",self.tit] image:nil location:nil urlResource:url presentedController:self completion:^(UMSocialResponseEntity *response){
        if (response.responseCode == UMSResponseCodeSuccess) {
                NSLog(@"分享成功！");
        }
    }];
        
       
    }else if (tag == 103){
        
        NSLog(@"朋友圈");
        
       UMSocialUrlResource *url = [[UMSocialUrlResource alloc]initWithSnsResourceType:(UMSocialUrlResourceTypeVideo) url:self.link];
        
    [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatTimeline] content:[NSString stringWithFormat:@"%@",self.tit] image:nil location:nil urlResource:url  presentedController:self completion:^(UMSocialResponseEntity *response){
        if (response.responseCode == UMSResponseCodeSuccess) {
                NSLog(@"分享成功！");
        }
    }];
        
        
    }else if (tag == 104){
  

    

        
        
        /**
         发送微博内容到多个微博平台
         
         @param platformTypes    分享到的平台，数组的元素是`UMSocialSnsPlatformManager.h`定义的平台名的常量字符串，例如`UMShareToSina`，`UMShareToTencent`等。
         @param content          分享的文字内容
         @param image            分享的图片,可以传入UIImage类型或者NSData类型
         @param location         分享的地理位置信息
         @param urlResource      图片、音乐、视频等url资源
         @param completion       发送完成执行的block对象
         @param presentedController 如果发送的平台微博只有一个并且没有授权，传入要授权的viewController，将弹出授权页面，进行授权。可以传nil，将不进行授权。
         
         */

 

        UMSocialUrlResource *image = [[UMSocialUrlResource alloc]initWithSnsResourceType:(UMSocialUrlResourceTypeVideo ) url:self.link];
        
    [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToQQ] content:[NSString stringWithFormat:@"%@",self.tit]  image:nil location:nil urlResource:image presentedController:self completion:^(UMSocialResponseEntity *response){
    if (response.responseCode == UMSResponseCodeSuccess) {
                        NSLog(@"分享成功！");
            }
        }];
       
        
    }else if (tag == 105){
        
        NSLog(@"QQ空间");
     UMSocialUrlResource *url = [[UMSocialUrlResource alloc]initWithSnsResourceType:(UMSocialUrlResourceTypeVideo) url:self.link];
        
        
    [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToQzone] content:[NSString stringWithFormat:@"%@",self.tit] image:nil location:nil urlResource:url  presentedController:self completion:^(UMSocialResponseEntity *response){
    if (response.responseCode == UMSResponseCodeSuccess) {
                        NSLog(@"分享成功！");
            }
        }];
        
    }else if (tag == 106){
            NSLog(@"腾讯");
        
               
        UMSocialUrlResource  * url = [[UMSocialUrlResource alloc]initWithSnsResourceType:(UMSocialUrlResourceTypeVideo) url:self.link ];

        [[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToTencent] content:[NSString stringWithFormat:@"%@",self.tit] image:nil location:nil urlResource:url presentedController:self completion:^(UMSocialResponseEntity *response) {
            
            if (response.responseCode == UMSResponseCodeSuccess) {
                NSLog(@"分享成功！");
            }
        }];
        
        

        
    }else if (tag == 107){
        NSLog(@"人人");
        
        UMSocialUrlResource *url = [[UMSocialUrlResource alloc]initWithSnsResourceType:(UMSocialUrlResourceTypeImage) url:self.link];
        [[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToRenren] content:[NSString stringWithFormat:@"%@",self.tit] image:nil location:nil urlResource:url  presentedController:self completion:^(UMSocialResponseEntity *response) {
            
            if (response.responseCode == UMSResponseCodeSuccess) {
                NSLog(@"分享成功！");
            }
        }];
   
    }else if (tag == 108){
        
        
        [[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToWechatFavorite] content:[NSString stringWithFormat:@"%@",self.tit] image:nil location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response) {
            
            if (response.responseCode == UMSResponseCodeSuccess) {
                NSLog(@"分享成功！");
            }
        }];


        
    }
    
}

@end
